package org.jeecg.config.jwt;

/**
 * @author: xiaYZ 2024/3/10
 * @version: 1.0
 */

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Arrays;
import java.util.List;

/***
 * description: 接口端拦截器配置
 * version: 1.0
 * date: 2022/5/26 11:46
 * @author: xiaYZ
 */
@Configuration
public class ApiInterceptorConfig implements WebMvcConfigurer {


    private static final List<String> API_EXCLUDE_PATH= Arrays.asList("/findUserById");
    @Bean
    public ApiHandlerInterceptor getMyHandlerInterceptor(){
        return new ApiHandlerInterceptor();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 自定义拦截器，添加拦截路径和排除拦截路径
        registry.addInterceptor(getMyHandlerInterceptor()).addPathPatterns("/**")
                .excludePathPatterns(API_EXCLUDE_PATH);
    }
}